<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>test.sql</title>
<meta name="generator" content="KF5::SyntaxHighlighting (SQL)"/>
</head><body style="color:#1f1c1b"><pre>
<span style="color:#898887;">-- comment</span>

<span style="font-weight:bold;">CREATE</span> <span style="font-weight:bold;">TABLE</span> stuff <span style="font-weight:bold;">COLUMNS</span>(col1 <span style="color:#0057ae;">INT</span>, col2 <span style="color:#0057ae;">Varchar</span>);
<span style="font-weight:bold;">SELECT</span> * <span style="font-weight:bold;">FROM</span> stuff <span style="font-weight:bold;">WHERE</span> <span style="font-weight:bold;">id</span> = <span style="color:#bf0303;">'string'</span>;
<span style="font-weight:bold;">select</span> * <span style="font-weight:bold;">from</span> stuff <span style="font-weight:bold;">where</span> <span style="font-weight:bold;">id</span> &lt; <span style="color:#b08000;">0.42</span>;
<span style="font-weight:bold;">Select</span> col1, col2 <span style="font-weight:bold;">From</span> stuff <span style="font-weight:bold;">Where</span> stuff.col1 <span style="font-weight:bold;">IS</span> <span style="font-weight:bold;">NOT</span> <span style="font-weight:bold;">NuLL</span>;

<span style="font-weight:bold;">CREATE</span> <span style="font-weight:bold;">TABLE</span> Persons (
    <span style="font-weight:bold;">ID</span> <span style="color:#0057ae;">int</span> <span style="font-weight:bold;">NOT</span> <span style="font-weight:bold;">NULL</span> AUTO_INCREMENT,
    LastName <span style="color:#0057ae;">varchar</span>(<span style="color:#b08000;">255</span>) <span style="font-weight:bold;">NOT</span> <span style="font-weight:bold;">NULL</span>,
    FirstName <span style="color:#0057ae;">varchar</span>(<span style="color:#b08000;">255</span>),
    Age <span style="color:#0057ae;">int</span>,
    <span style="font-weight:bold;">PRIMARY</span> <span style="font-weight:bold;">KEY</span> (<span style="font-weight:bold;">ID</span>)
    <span style="font-weight:bold;">CONSTRAINT</span> CHK_Person <span style="font-weight:bold;">CHECK</span> (Age&gt;=<span style="color:#b08000;">18</span> <span style="font-weight:bold;">AND</span> City=<span style="color:#bf0303;">'Sandnes'</span>)
);

<span style="font-weight:bold;">SELECT</span> column_name(s)
<span style="font-weight:bold;">FROM</span> table1
<span style="font-weight:bold;">FULL</span> <span style="font-weight:bold;">OUTER</span> <span style="font-weight:bold;">JOIN</span> table2 <span style="font-weight:bold;">ON</span> table1.column_name = table2.column_name;

<span style="font-weight:bold;">SELECT</span> * <span style="font-weight:bold;">FROM</span> Customers
<span style="font-weight:bold;">WHERE</span> City <span style="font-weight:bold;">LIKE</span> <span style="color:#bf0303;">'[bsp]%'</span>;

<span style="font-weight:bold;">SELECT</span> <span style="color:#644a9b;">Count</span>(*) <span style="font-weight:bold;">AS</span> DistinctCountries
<span style="font-weight:bold;">FROM</span> (<span style="font-weight:bold;">SELECT</span> <span style="font-weight:bold;">DISTINCT</span> Country <span style="font-weight:bold;">FROM</span> Customers)
<span style="font-weight:bold;">GROUP</span> <span style="font-weight:bold;">BY</span> Country
<span style="font-weight:bold;">HAVING</span> <span style="color:#644a9b;">COUNT</span>(CustomerID) &gt; <span style="color:#b08000;">5</span>
<span style="font-weight:bold;">ORDER</span> <span style="font-weight:bold;">BY</span> <span style="color:#644a9b;">COUNT</span>(CustomerID) <span style="font-weight:bold;">DESC</span>;

<span style="font-weight:bold;">SELECT</span> <span style="color:#bf0303;">'Customer'</span> <span style="font-weight:bold;">As</span> <span style="font-weight:bold;">Type</span>, ContactName, City, Country
<span style="font-weight:bold;">FROM</span> Customers
<span style="font-weight:bold;">UNION</span>
<span style="font-weight:bold;">SELECT</span> <span style="color:#bf0303;">'Supplier'</span>, ContactName, City, Country
<span style="font-weight:bold;">FROM</span> Suppliers;

<span style="font-weight:bold;">SELECT</span> <span style="color:#644a9b;">COUNT</span>(ProductID), <span style="color:#644a9b;">AVG</span>(Price)
<span style="font-weight:bold;">FROM</span> Products;

<span style="font-weight:bold;">SET</span> lock_timeout = <span style="color:#b08000;">0</span>;
<span style="font-weight:bold;">SET</span> client_encoding = <span style="color:#bf0303;">'UTF8'</span>;
<span style="font-weight:bold;">SET</span> standard_conforming_strings = <span style="font-weight:bold;">on</span>;
<span style="font-weight:bold;">SET</span> check_function_bodies = <span style="font-weight:bold;">false</span>;
<span style="font-weight:bold;">SET</span> client_min_messages = warning;
<span style="font-weight:bold;">SET</span> default_tablespace = <span style="color:#bf0303;">''</span>;

<span style="font-weight:bold;">DROP</span> <span style="font-weight:bold;">TABLE</span> <span style="font-weight:bold;">IF</span> <span style="font-weight:bold;">EXISTS</span> employees;

<span style="font-weight:bold;">ALTER</span> <span style="font-weight:bold;">TABLE</span> <span style="font-weight:bold;">ONLY</span> employees
    <span style="font-weight:bold;">ADD</span> <span style="font-weight:bold;">CONSTRAINT</span> fk_employees_employees <span style="font-weight:bold;">FOREIGN</span> <span style="font-weight:bold;">KEY</span> (reportsto) <span style="font-weight:bold;">REFERENCES</span> employees;

<span style="font-weight:bold;">CREATE</span> <span style="font-weight:bold;">VIEW</span> [<span style="font-weight:bold;">Current</span> Product <span style="font-weight:bold;">List</span>] <span style="font-weight:bold;">AS</span>
<span style="font-weight:bold;">SELECT</span> ProductID, ProductName
<span style="font-weight:bold;">FROM</span> Products
<span style="font-weight:bold;">WHERE</span> Discontinued = <span style="font-weight:bold;">No</span>;

<span style="font-weight:bold;">SELECT</span> * <span style="font-weight:bold;">FROM</span> [<span style="font-weight:bold;">Current</span> Product <span style="font-weight:bold;">List</span>];

<span style="font-weight:bold;">SELECT</span> * <span style="font-weight:bold;">FROM</span> [<span style="font-weight:bold;">Category</span> Sales <span style="font-weight:bold;">For</span> <span style="color:#b08000;">1997</span>]
<span style="font-weight:bold;">WHERE</span> CategoryName = <span style="color:#bf0303;">'Beverages'</span>;

<span style="font-weight:bold;">begin</span>
<span style="font-weight:bold;">end</span>
<span style="color:#924c9d;">/</span>
 /
/ u
</pre></body></html>
